%Redirect to parent directory
functionFolder = cd('..');

%Spreadsheet options
opts = spreadsheetImportOptions("NumVariables", 21);

% Specify sheet and range
opts.Sheet = "Sheet2";
opts.DataRange = "A2:U3392";

% Specify column names and types
opts.VariableNames = ["VarName1", "MTBills", "EURSpot", "Euro3MForward", "MEURGerman", "AUDSpot", "AUD3MForward", "AUD3MYield", "CADSpot", "CAD3MForward", "CAD3MYield", "GBPSpot", "GBP3MForward", "GBP3MYield", "JPYSpot", "JPY3MForward", "JPY3MYield","EURIBOR3MYield","CHF3MYield","EURCHFSpot","EURCHF3MForward"];
opts.VariableTypes = ["datetime", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double" ,"double", "double", "double", "double"];

% Specify variable properties
opts = setvaropts(opts, "VarName1", "InputFormat", "");

% Import the data
oldFolder = cd('input\');
CIPAllS1 = readtable("CIPAll_WithCHF.xlsx", opts, "UseExcel", false);
cd(functionFolder);

% Clear temporary variables
clear opts
% Compute cross-currency basis for each currency using Bloomberg data from
% the above imported file
CIPVecEUR = CIPAllS1{:,[3 4 2 5]};
CIPCalcEUR = (CIPVecEUR(:,1)./CIPVecEUR(:,2)).*(1./(1+CIPVecEUR(:,4)./100)).^0.25 - (1./(1+CIPVecEUR(:,3)./100)).^0.25;
CIPVecAUD = CIPAllS1{:,[6 7 2 8]};
CIPCalcAUD = (CIPVecAUD(:,1)./CIPVecAUD(:,2)).*(1./(1+CIPVecAUD(:,4)./100)).^0.25 - (1./(1+CIPVecAUD(:,3)./100)).^0.25;
CIPVecCAD = CIPAllS1{:,[9 10 2 11]};
CIPCalcCAD = (CIPVecCAD(:,1)./CIPVecCAD(:,2)).*(1./(1+CIPVecCAD(:,4)./100)).^0.25 - (1./(1+CIPVecCAD(:,3)./100)).^0.25;
CIPVecGBP = CIPAllS1{:,[12 13 2 14]};
CIPCalcGBP = (CIPVecGBP(:,1)./CIPVecGBP(:,2)).*(1./(1+CIPVecGBP(:,4)./100)).^0.25 - (1./(1+CIPVecGBP(:,3)./100)).^0.25;
CIPVecJPY = CIPAllS1{:,[15 16 2 17]};
CIPCalcJPY = (CIPVecJPY(:,1)./CIPVecJPY(:,2)).*(1./(1+CIPVecJPY(:,4)./100)).^0.25 - (1./(1+CIPVecJPY(:,3)./100)).^0.25;
CIPVecEURCHF = CIPAllS1{:,[20 21 19 18]};
CIPCalcEURCHF = (CIPVecEURCHF(:,1)./CIPVecEURCHF(:,2)).*(1./(1+CIPVecEURCHF(:,4)./100)).^0.25 - (1./(1+CIPVecEURCHF(:,3)./100)).^0.25;
